import datetime
import time


def timeit(fn):
  """
  timeit function is able to calculate the running time of a function.
  """
  def wrapper(*args,**kwargs):
    start = datetime.datetime.now()
    for i in range(5):
      ret = fn(*args,**kwargs)
    duration  = (datetime.datetime.now() - start)/5
    print("function {} took {}s".format(fn.__name__, duration.total_seconds()))
    return ret
  return wrapper

@timeit
def add(x,y):
  """
  sum two numbers
  """
  time.sleep(1)
  return x+y

if __name__ == '__main__':
    test = add(1,3)